/*
 * Copyright (c) 2006, 2021, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.util.*;

/**
 * <p>Project: javase - Map2
 * <p>Powered by webrx On 2021-12-10 14:22:18
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class Map2 {
    public static void main(String[] args) {

        var m = new HashMap<String, String>();
        m.put("k1", "java");
        m.put("k5", "html");
        m.put("k234241", "c");
        m.put("k3", "go");
        m.put("abc", "mysql");
        m.put("k0", "css");
        m.put("k16", "java");
        System.out.println(m);
        System.out.println(m.keySet());
        //Set<String> 是key类型
        var k = new ArrayList<>(m.keySet());
        System.out.println(k);
        //list排升序
        //k.sort(Comparator.naturalOrder());
        //list排降序
        //k.sort(Comparator.reverseOrder());
        //使用Collections工具类shffle(List) 乱序
        //Collections.shuffle(k);

        //根据字符串长度进行排序 升序
        k.sort(Comparator.comparingInt(String::length));
        //根据字符串长度进行排序 降序
        k.sort((x, y) -> y.length() - x.length());
        System.out.println(k);


        //List<String> 是value类型
        var v = new ArrayList<>(m.values());
        System.out.println(v);

        System.out.println(m);
    }
}
